'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const db = uniCloud.database();
	const userInfo = await db.collection('uni-id-users').where({
		user: event.user
	}).count();
	if (userInfo.total > 0) {
		return {
			code: 400,
			msg: '用户已存在！'
		}
	} else {
		db.collection('uni-id-users').add({
			user: event.user,
			password: event.password
		})
		return {
			code: 200,
			msg: '注册成功！'
		}
	}
};
